package com.baizw.cultivation.module.admin.mapstruct;

import com.baizw.cultivation.module.admin.entity.RoleEntity;
import com.baizw.cultivation.module.admin.entity.UserEntity;
import com.baizw.cultivation.module.admin.entity.vo.UserVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

/**
 * 用户转换
 *
 * @author 剧终1204
 * @version V1.0
 * @date 2020年04月27日 15:46
 */
@Mapper(componentModel = "spring")
public interface UserMapstruct {

    /**
     * 转化用户视图对象
     *
     * @param user    用户对象
     * @param role    角色对象
     * @return
     */
    @Mappings({
            @Mapping(source = "user.id", target = "id"),
            @Mapping(source = "user.name", target = "name"),
            @Mapping(source = "user.creatorId", target = "creatorId"),
            @Mapping(source = "role.id", target = "roleId"),
            @Mapping(source = "role", target = "role"),
    })
    UserVO convert(UserEntity user, RoleEntity role);
}
